#include <mod/include/EEPROM.h>

/***********************************************************************************************************************
*
*        EEPROM.
*
*        Versie 0.1  30/05/2010
*        Opstellen EEPROM programma.
*
*        Versie 0.2  03/06/2010
*        Uitbreiden.
*
***********************************************************************************************************************/


//------------------------------------------- Functies -------------------------------------------

void EEPROM_Write(unsigned int EData,unsigned int adress)
{
  unsigned char adresses[2],slave;
  adresses[0]=adress>>8;
  adresses[1]=adress;
  if(adress>65535){
     slave=0x51;
  }else{
     slave=0x50;
  }
  TWI_Start(slave,0);
  TWI_Write(adresses[0]);
  TWI_Write(adresses[1]);
  TWI_Write(EData);
  TWI_Stop();
}

int EEPROM_Read(unsigned int adress)                        
{
  unsigned char adresses[2],slave,ERead,ERead1;
  adresses[1]=adress>>8;
  adresses[0]=adress;
  if(adress>65535){
     slave=0x51;
  }else{
     slave=0x50;
  }
  TWI_Start1(slave,1,&adresses,2);  
  TWI_Stop();
  ERead = TWI_Read();
  return(ERead);
}



